package com.ruoyi.bath.request.service.impl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Options;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bath.request.mapper.RequestMapper;
import com.ruoyi.bath.request.domain.Request;
import com.ruoyi.bath.request.service.IRequestService;

/**
 * 申请信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-08-06
 */
@Service
public class RequestServiceImpl implements IRequestService
{
    @Autowired
    private RequestMapper requestMapper;

    /**
     * 查询申请信息
     * 
     * @param
     * @return 申请信息
     */
    @Override
    public List<Request> selectRequest(Request request)
    {
        return (List<Request>) requestMapper.selectRequest(request);
    }

    /**
     * 查询申请信息列表
     * 
     * @param request 申请信息
     * @return 申请信息
     */
    @Override
    public List<Request> selectRequestList(Request request)
    {
        return requestMapper.selectRequestList(request);
    }

    /**
     * 新增申请信息
     * 
     * @param request 申请信息
     * @return 结果
     */
    @Override
    public int insertRequest(Request request)
    {
  SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
 System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
request.setRequestTime(df.format(new Date()));
        return requestMapper.insertRequest(request);
    }

    /**
     * 修改申请信息
     * 
     * @param request 申请信息
     * @return 结果
     */
    @Override
    public int updateRequest(Request request)
    {
        return requestMapper.updateRequest(request);
    }

    /**
     * 批量删除申请信息
     * 
     * @param ids 需要删除的申请信息主键
     * @return 结果
     */
    @Override
    public int deleteRequestByIds(Long[] ids)
    {
        return requestMapper.deleteRequestByIds(ids);
    }

    /**
     * 删除申请信息信息
     * 
     * @param id 申请信息主键
     * @return 结果
     */
    @Override
    public int deleteRequestById(Long id)
    {
        return requestMapper.deleteRequestById(id);
    }
//根据首页预约进行添加时间段
    @Override
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    public void insertaddRequestTime(Request request) {

        requestMapper.insertaddRequestTime(request);
    }

    @Override
    public void deletemsg(Integer id) {
        requestMapper.deletemsg(id);



    }
}
